//
//  HomepageViewController.m
//  登录界面
//
//  Created by 刘波岐 on 16/9/2.
//  Copyright © 2016年 刘波岐. All rights reserved.
//

#import "HomepageViewController.h"

@interface HomepageViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UIImageView *icon;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *funsLabel;
@property (weak, nonatomic) IBOutlet UILabel *signLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *iconWidth;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *iconToTopDistance;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *backimageHeight;
@property (weak, nonatomic) IBOutlet UITableView *tableV;

@end

@implementation HomepageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.tableV.delegate = self;
    self.tableV.dataSource = self;
    self.tableV.backgroundColor = [UIColor clearColor];
    //注册表格
    [self.tableV registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
    self.navigationController.navigationBar.alpha = 0;
    [self.navigationController setNavigationBarHidden:YES animated:YES];
//    头像
    self.icon.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.iconStr]]];
    self.icon.layer.masksToBounds = YES;
    self.icon.layer.cornerRadius = 30;
//    昵称
    self.nameLabel.text = self.nameStr;
    self.nameLabel.textColor = [UIColor whiteColor];
//    关注 粉丝
    self.funsLabel.text = [NSString stringWithFormat:@"关注 %@        粉丝 %@",self.friendCount,self.funsStr];
    self.funsLabel.textColor = [UIColor whiteColor];
//    签名
    self.signLabel.text = [NSString stringWithFormat:@"简介:%@",self.signStr];
    self.signLabel.textColor = [UIColor whiteColor];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 20;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    return cell;
}
//头视图高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 240;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [[UIView alloc] initWithFrame:CGRectZero];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    self.iconToTopDistance.constant  = 90 - scrollView.contentOffset.y;
    self.backimageHeight.constant = 242 - scrollView.contentOffset.y;
    //    self.titleWidth.constant  = 60 - scrollView.contentOffset.y;
    if (scrollView.contentOffset.y > 20) {
        self.navigationController.navigationBar.alpha = scrollView.contentOffset.y / 150;
        [self.navigationController setNavigationBarHidden:NO animated:YES];
    } else {
        self.navigationController.navigationBar.alpha = 0;
        [self.navigationController setNavigationBarHidden:YES animated:YES];
    }

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
